package com.dykj.fireFighting.web.devhis;

import com.dykj.fireFighting.api.elasticsearch.devHisZc.entity.EsDevHisZc;
import com.dykj.fireFighting.api.elasticsearch.devHisZc.service.EsDevHisZcService;
import com.dykj.fireFighting.api.socialUnit.devHis.dto.DevHisElectricalDto;
import com.dykj.fireFighting.api.socialUnit.devHis.entity.DevHisElectrical;
import com.dykj.fireFighting.api.socialUnit.devHis.service.IDevHisElectricalService;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;




/**
 * 电气火灾报警设备运行记录接口
 *
 * @Author fgc
 * @Date  2021-06-21 10:58:04
 */
@Slf4j
@Api(value = "电气火灾报警设备运行记录接口", tags = {"电气火灾报警设备运行记录接口"})
@RestController
@RequestMapping("devHis/devHisElectrical")
public class DevHisElectricalController {
   @DubboReference
    private IDevHisElectricalService devHisElectricalService;
    @DubboReference
    private EsDevHisZcService esDevHisZcService;


    /**
     * 电气火灾报警设备运行记录列表
     *
     * @return
     */
    @AutoLog(value = "电气火灾报警设备运行记录-分页列表查询")
    @ApiOperation(value = "电气火灾报警设备运行记录分页列表", notes = "电气火灾报警设备运行记录分页列表")
    @GetMapping("/list")
    public CommonResult<PageVo<EsDevHisZc>> treeGrid(DevHisElectricalDto devHisElectricalDto) {
        Long enterpriseId = ShiroUtil.getUser().getEnterpriseId();
        devHisElectricalDto.setUnitId(enterpriseId+"");
        PageVo<EsDevHisZc> page = esDevHisZcService.searchByCenterId("",enterpriseId + "", devHisElectricalDto.getName(),(int) devHisElectricalDto.getPage(), (int) devHisElectricalDto.getLimit(),
                devHisElectricalDto.getBeginDate(),devHisElectricalDto.getEndDate());
        return CommonResult.success(page);
    }

    /**
     * 获取电气火灾报警设备运行记录信息
     */
    @AutoLog(value = "电气火灾报警设备运行记录-获取VIEW信息")
    @ApiOperation(value = "获取电气火灾报警设备运行记录信息", notes = "获取电气火灾报警设备运行记录信息")
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", dataType = "Long", required = true)
    @GetMapping("/info/{id}")
    @RequiresPermissions("devHis/devHisElectrical/info")
    public CommonResult<DevHisElectrical> info(@PathVariable("id") Long id){
        DevHisElectrical devHisElectrical = devHisElectricalService.getById(id);
        return CommonResult.success(devHisElectrical);
    }


}
